package com.kfm.base.io.c;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Demo {

    public static void main(String[] args) {
        try(FileReader fr = new FileReader("d://io/file-reader.txt")){
            // 读取单个字符
//            int read = fr.read();
//            System.out.println((char)read);

//            int read;
//            while((read = fr.read()) != -1){
//                System.out.print((char)read);
//            }

            // 读取多个字符
            char[] chars = new char[3];

            int size;
            while( (size = fr.read(chars)) != -1){
                System.out.println(new String(chars, 0, size));
            }



        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
